
package ch.hearc.meteo.imp.afficheur.real.moo;

import java.awt.Color;
import java.util.ArrayList;
import java.util.List;

import javax.swing.table.AbstractTableModel;

public class MeteoTableModel extends AbstractTableModel
	{

	List<StationMeteoElement> meteoStationList;

	String[] headerList = { "Nom", "Altitude [m]", "Pression [mb]", "Température [°C]" };
//	String[] headerList = { "Nom", "a", "b", "c" };

	@SuppressWarnings("rawtypes")
	Class[] classes = { String.class, Float.class, Float.class, Float.class };

	public MeteoTableModel(ArrayList<StationMeteoElement> meteoStationList)
		{
		this.meteoStationList = meteoStationList;
		}

	/*------------------------------------------------------------------*\
	|*							Constructeurs							*|
	\*------------------------------------------------------------------*/

	/*------------------------------------------------------------------*\
	|*							Methodes Public							*|
	\*------------------------------------------------------------------*/

	/*------------------------------*\
	|*				Set				*|
	\*------------------------------*/

	/*------------------------------*\
	|*				Get				*|
	\*------------------------------*/

	@Override
	public int getColumnCount()
		{
		return headerList.length;
		}

	@Override
	public int getRowCount()
		{
		return meteoStationList.size();
		}

	@Override
	public Object getValueAt(int row, int column)
		{
		StationMeteoElement element = null;
		element = meteoStationList.get(row);
		switch(column)
			{
			case 0:
				return element.getAffichageOption().getTitre();
			case 1:
				return element.getStatAltitude().getLast();
			case 2:
				return element.getStatPression().getLast();
			case 3:
				return element.getStatTemperature().getLast();
			}
		return "";
		}

	@Override
	public String getColumnName(int column)
		{
		return headerList[column];
		}


	public Color getRowColor(int row)
		{
		return meteoStationList.get(row).getGraphColor();
		}

	@Override
	public Class<?> getColumnClass(int column)
		{
		return classes[column];
		}
	/*------------------------------------------------------------------*\
	|*							Methodes Private						*|
	\*------------------------------------------------------------------*/

	/*------------------------------------------------------------------*\
	|*							Attributs Private						*|
	\*------------------------------------------------------------------*/
	}
